package com.sasu.university_data.util;

import lombok.Data;

@Data
public class Resp<T> {

    private Integer code;
    private String msg;
    private T data;

    public Resp ( Integer code, String msg, T data ) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public Resp ( Integer code, String msg ) {
        this.code = code;
        this.msg = msg;
    }

    public Resp ( Integer code, T data ) {
        this.data = data;
    }

    public Resp ( T data ) {
        this.data = data;
    }

    public static <T> Resp<T> success ( T data ){

        return new Resp<>(200,"success",data);

    }
    public static <T> Resp<T> success(){
        return new Resp<>(200,"success");
    }

    public static <T> Resp<T> success (String msg, T data ){

        return new Resp<>(200,msg,data);

    }

    public static <T> Resp<T> failed(String msg){
        return new Resp<>(400,msg);
    }

    public static <T> Resp<T> failed(){
        return new Resp<>(400,"error");
    }

    public static <T> Resp<T> failed(Integer code,String msg){
        return new Resp<>(code, msg);
    }

}
